/* Module: mouse.h
 * Author: Konstantin Wurster
 * Notice: All structures are obtained by analysis. They may be wrong.
 */

#ifndef _MOUSE_PX_
#define _MOUSE_PX_

#include <WinDef.h>

/* hid of the mouse. TODO: retrieve this dynamic so others can use this tool, too! */
#define MOUSE_HID TEXT("\\\\?\\hid#vid_1ea7&pid_002c&mi_02&col01#8&30134b74&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}")

/* magic signature of datapackets. */
#define MOUSE_MAGIC 0xb3

/* mouse commands. */
#define MOUSE_CMD_SETPROFILE 0x20
#define MOUSE_CMD_DUMMY 0x23

/* unknown parameters. */
#define MOUSE_SETPROFILE_UNK 0x08

/* a mouse is only represented by its file handle. */
typedef HANDLE MOUSE;


/* datatype for switching the profile. */
typedef struct _MOUSE_CHANGEPROFILE {
	BYTE unknown;
	BYTE profile;
} MOUSE_CHANGEPROFILE, *PMOUSE_CHANGEPROFILE;

/* dummy to get the proper structsize. */
typedef struct _MOUSE_DUMMY {
	BYTE unknown[6];
} MOUSE_DUMMY;

/* the datastructure for communication. */
typedef struct _MOUSE_DATA {
	BYTE magic;
	BYTE cmd;
	union {
		MOUSE_CHANGEPROFILE changeprofile;
		MOUSE_DUMMY dummy;
	} d;
} MOUSE_DATA, *PMOUSE_DATA;


/* returns a handle to the mouse, it must be closed with closeMouseHandle. */
MOUSE openMouseHandle();

/* closes the mouse handle. */
void closeMouseHandle(MOUSE mouse);

/* selects and applies a profile. */
void setMouseProfile(MOUSE mouse, BYTE index);


#endif